package com.wnn.demo.model.business.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wnn.demo.model.business.entity.ProductInfo;
import com.wnn.demo.model.business.mapper.ProductInfoMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ProductInfoService {

    @Resource
    private ProductInfoMapper productInfoMapper;

    public PageInfo<ProductInfo> queryProduct(Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<ProductInfo> productInfo = productInfoMapper.queryProduct();
        return new PageInfo<>(productInfo);

    }

    /**
     *
     * @param productInfo
     * @return
     */
    public Boolean addProduct(ProductInfo productInfo) {
        return productInfoMapper.addProduct(productInfo);
    }

    public Boolean deleteProduct(Integer productId) {
        return productInfoMapper.deleteProduct(productId);
    }

    public Boolean updateProduct(ProductInfo productInfo) {
        return productInfoMapper.updateProduct(productInfo);
    }
}
